<?php

use think\facade\Route;

Route::group('api', function () {
    Route::post('code/send', 'Code/send')->name('code.send');
    Route::post('auth/register', 'Auth/register')->name('register');
    Route::post('auth/login', 'Auth/login')->name('login');
    Route::resource('cat', 'Cat')->except(['create', 'edit']);
    Route::resource('topic', 'Topic')->except(['create', 'edit']);
    //添加某条评论
    Route::post('comment/:topic_id','Comment/save')->name('comment.save');
    //删除某条评论
    Route::delete('comment/:comment_id','Comment/delete')->name('comment.delete');
    //针对某条评论的评论
    Route::post('reply/comment/:topic_id/:comment_id','Comment/replyComment')->name('reply.comment');
    //某帖子下的评论列表
    Route::get('list/comment/:topic_id','Comment/index')->name('comment.list');
    Route::get('favorite/toggle/:topic_id','Favorite/toggle')->name('favorite.toggle');
    Route::post('upload/image','Attachment/image')->name('upload.image');
    Route::get('test', 'Test/api');
})->middleware('rate');

Route::get('test', 'Test/test')->name('test');
